package com.iotechn.unimall.data.dto.excel;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;

/**
 * 商品统计
 *
 * @author kyms
 * @date 2020-06-24 18:00
 */
@ExcelTarget("skuTotalSummaryDTO")
@Data
public class SkuTotalSummaryDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long skuId;
    //标识，用于排序
    private Long id;
    @Excel(name = "条码", width = 15d)
    private String barCode;
    @Excel(name = "商品名称", width = 15d)
    private String spuTitle;
    @Excel(name = "规格", width = 15d)
    private String skuTitle;
    @Excel(name = "单位")
    private String unit;

    /** 商品分类id */
    @Excel(name = "商品分类id")
    private Long categoryId;
    /** 商品分类id */
    @Excel(name = "商品分类名称")
    private String categoryName;
    //  @Excel(name = "销售总数", isColumnHidden = false)
    private Float num;
    //    @Excel(name = "期初库存")
    //  private Float startStock;
    // @Excel(name = "目前库存", isColumnHidden = false)
    private Float stock;
    // @Excel(name = "入库", isColumnHidden = false)
    private Float inNum;
    // @Excel(name = "报损", isColumnHidden = false)
    private Float lossNum;

    // @Excel(name = "调入", isColumnHidden = false)
    private Float allotInNum;
    //  @Excel(name = "调出", isColumnHidden = false)
    private Float allotOutNum;


    @ExcelEntity(name = "期初库存")
    private SkuTotalPriceDTO startStock = new SkuTotalPriceDTO();
    @ExcelEntity(name = "入库")
    private SkuTotalPriceDTO purchaseStock = new SkuTotalPriceDTO();
    @ExcelEntity(name = "线上销售")
    private SkuTotalPriceDTO onlineStock = new SkuTotalPriceDTO();
    @ExcelEntity(name = "门店销售")
    private SkuTotalPriceDTO offlineStock = new SkuTotalPriceDTO();

    @ExcelEntity(name = "出库")
    private SkuTotalPriceDTO salesSendStock = new SkuTotalPriceDTO();

    @ExcelEntity(name = "报损")
    private SkuUnitPriceDTO commonLossStock = new SkuUnitPriceDTO();

    @ExcelEntity(name = "品鉴")
    private SkuUnitPriceDTO tasteLossStock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "调入")
    private SkuUnitPriceDTO allotInStock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "调出")
    private SkuUnitPriceDTO allotOutStock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "退库")
    private SkuUnitPriceDTO returnStock = new SkuUnitPriceDTO();

    @ExcelEntity(name = "门店退货统计")
    private SkuUnitPriceDTO returnGoodstoStoreSrock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "退供应商")
    private SkuUnitPriceDTO returnSupplierStock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "盘盈")
    private SkuUnitPriceDTO checkAddStock = new SkuUnitPriceDTO();


    @ExcelEntity(name = "盘亏")
    private SkuUnitPriceDTO checkSubStock = new SkuUnitPriceDTO();

    @ExcelEntity(name = "期末库存")
    private SkuTotalPriceDTO endStock = new SkuTotalPriceDTO();
    //
//    //    @Excel(name = "盘库", isColumnHidden = false)
//    private Float stockCheckNum;
    //@Excel(name = "线上销售")
    private Float onlineNum;

    //@Excel(name = "门店销售")
    private Float offlineNum;
    //    @Excel(name = "门店退款")
    private Float offlineRefundNum;
    //  @Excel(name = "退库", isColumnHidden = false)
    private Float returnNum;
    //  @Excel(name = "退货")
    private Float returnSupplierNum;

    // @Excel(name = "出库", isColumnHidden = false)
    private Float outNum;

    private Float inPrice;

    private Float inTotalPrice;

    private Float stockCheckAddNum;

    private Float stockCheckAddPrice;

    private Float stockCheckSubNum;

    private Float stockCheckSubPrice;

    private String time;


    public Float getInTotalPrice() {
        if (this.inNum == null || this.inPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.inPrice * this.inNum);
        return Float.valueOf(total);
    }

    public Float getStockCheckAddPrice() {
        if (this.inPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.inPrice * this.stockCheckAddNum);
        return Float.valueOf(total);
    }

    public Float getStockCheckSubPrice() {
        if (this.inPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.inPrice * this.stockCheckSubNum);
        return Float.valueOf(total);
    }


    public Float getInPrice() {
        if (this.inPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.inPrice);
        return Float.valueOf(total);
    }
}
